package com.baizhi.service.impl;

import com.baizhi.dao.BookDao;
import com.baizhi.entity.Book;
import com.baizhi.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class BookServiceImpl implements BookService {
    @Autowired
    private BookDao bookDao;

    @Override
    public List<Book> showBooks(Integer pageNum, Integer pageSize) {
        List<Book> books = bookDao.selectBooks(pageNum, pageSize);
        return books;
    }

    @Override
    public Book showBookById(Integer id) {
       return bookDao.selectBookById(id);
    }

    @Override
    public void addBook(Book b) {
        bookDao.insertBook(b);
    }

    @Override
    public void removeBookById(Integer id) {
      bookDao.deleteBookById(id);
    }

    @Override
    public void updateBook(Book b) {
      bookDao.updateBook(b);
    }
}
